<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;

class StoreBargainUserHelp extends Model
{
    use HasFactory;
    protected $table = 'store_bargain_user_help';
    protected $guarded = [];

    /**
     * 用户表
     * @return \Illuminate\Database\Eloquent\Relations\HasOne
     */
    public function user(){
        return $this->hasOne(User::class,'uid','uid');
    }

    /**
     * 获取用户帮砍信息
     * @param $id
     * @return \Illuminate\Database\Eloquent\Builder[]|\Illuminate\Database\Eloquent\Collection
     */
    public static function getStoreBargainUserHelp($id){
        return self::with('user')->where('bargain_user_id',$id)->get();
    }

    /**
     * 获取一条信息
     * @param $uid
     * @return mixed
     */
    public static function storeBargainUserHelpFind($uid){
        return self::where('uid',$uid)->first();
    }

    /**
     * 添加
     * @param $data
     * @return mixed
     */
    public static function storeBargainUserHelpSave($data){
        return self::insert($data);
    }
}
